package org.linlinjava.litemall.admin.web.order_manage;

import org.linlinjava.litemall.admin.form.*;
import org.linlinjava.litemall.admin.service.order_manage.AgedmallHomeSettingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@RestController
@RequestMapping("/homeSetting")
public class AgedmallHomeSettingController {

    @Autowired
    private AgedmallHomeSettingService agedmallHomeSettingService;

    @PostMapping("addAd")
    public Object addAd(@RequestBody @Valid HomeAddAdListForm homeAddAdListForm){
        return agedmallHomeSettingService.addAd(homeAddAdListForm);
    }

    @PostMapping("adList")
    public Object adList(){
        return agedmallHomeSettingService.adList();
    }

    @PostMapping("addSalePoint")
    public Object addSalePoint(@RequestBody @Valid HomeAddSalePointListForm homeAddAdListForm){
        return agedmallHomeSettingService.addSalePoint(homeAddAdListForm);
    }

    @PostMapping("salePointList")
    public Object salePointList(){
        return agedmallHomeSettingService.salePointList();
    }

    @PostMapping("addRecommendPic")
    public Object addRecommendPic(@RequestBody @Valid HomeAddRecommendPicForm homeAddRecommendPicForm){
        return agedmallHomeSettingService.addRecommendPic(homeAddRecommendPicForm);
    }

    @PostMapping("recommendPic")
    public Object recommendPic(@RequestParam String type){
        return agedmallHomeSettingService.recommendPic(type);
    }

    @PostMapping("addRecommend")
    public Object addRecommend(@RequestBody @Valid HomeAddRecommendForm homeAddRecommendForm){
        return agedmallHomeSettingService.addRecommend(homeAddRecommendForm);
    }

    @PostMapping("recommend")
    public Object recommend(@RequestParam String type){
        return agedmallHomeSettingService.recommend(type);
    }

    @PostMapping("addTopic")
    public Object addTopic(@RequestBody @Valid HomeAddTopicForm homeAddTopicForm){
        return agedmallHomeSettingService.addTopic(homeAddTopicForm);
    }

    @PostMapping("topic")
    public Object topic(@RequestParam Integer type){
        return agedmallHomeSettingService.topic(type);
    }

    @PostMapping("goodsList")
    public Object goodsList(@RequestParam(required = false) Integer categoryId,
                            @RequestParam(required = false) Integer subCategoryId,
                            @RequestParam(required = false) String type,
                            @RequestParam(required = false) String searchKey,
                            @RequestParam(defaultValue = "1") Integer page,
                            @RequestParam(defaultValue = "10") Integer limit){
        return agedmallHomeSettingService.goodsList(categoryId, subCategoryId, type, searchKey, page, limit);
    }
}
